package com.wzg.web.service.impl;

import com.wzg.rpc.pojo.TbItem;
import com.wzg.rpc.service.ItemService;
import com.wzg.web.service.ManagerItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.EgoResult;
import pojo.PageResult;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;

@Service
public class ManagerItemServiceImpl implements ManagerItemService {

    //注入的是远程服务的代理对象
    @Autowired
    private ItemService itemServiceProxy;
    @Override
    public PageResult<TbItem> selectItemListService(Integer page, Integer rows) {
        // TODO Auto-generated method stub
        return itemServiceProxy.selectItemList(page, rows);
    }
    @Override
    public EgoResult reshelfItem(BigDecimal[] ids) {
        // TODO Auto-generated method stub
        //将ids数组转化为List集合
        List<BigDecimal> itemIds = Arrays.asList(ids);
        //调用远程服务
        return itemServiceProxy.updateItemStatus(itemIds, true);
    }
    @Override
    public EgoResult instockItem(BigDecimal[] ids) {
        // TODO Auto-generated method stub
        //将ids数组转化为List集合
        List<BigDecimal> itemIds = Arrays.asList(ids);
        return itemServiceProxy.updateItemStatus(itemIds, false);
    }
    @Override
    public EgoResult delteItemService(BigDecimal[] ids) {
        // TODO Auto-generated method stub
        List<BigDecimal> itemIds = Arrays.asList(ids);
        //调用远程删除商品信息的服务
        return itemServiceProxy.deleteItem(itemIds);

    }
}
